home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / tree / VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration.class (.txt) < prev   
Encoding:
Java Class File  |  1999-07-15  |  2.3 KB  |  94 lines

  1. package javax.swing.tree;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.NoSuchElementException;
  5.  
  6. class VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration implements Enumeration {
  7.    // $FF: synthetic field
  8.    private final VariableHeightLayoutCache this$0;
  9.    protected VariableHeightLayoutCache.TreeStateNode parent;
  10.    protected int nextIndex;
  11.    protected int childCount;
  12.  
  13.    protected VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration(VariableHeightLayoutCache var1, VariableHeightLayoutCache.TreeStateNode var2) {
  14.       this(var1, var2, -1);
  15.    }
  16.  
  17.    protected VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration(VariableHeightLayoutCache var1, VariableHeightLayoutCache.TreeStateNode var2, int var3) {
  18.       this.this$0 = var1;
  19.       this.parent = var2;
  20.       this.nextIndex = var3;
  21.       this.childCount = this.parent.getChildCount();
  22.    }
  23.  
  24.    protected boolean findNextValidParent() {
  25.       if (this.parent == VariableHeightLayoutCache.access$2(this.this$0)) {
  26.          this.parent = null;
  27.          return false;
  28.       } else {
  29.          while(this.parent != null) {
  30.             VariableHeightLayoutCache.TreeStateNode var1 = (VariableHeightLayoutCache.TreeStateNode)this.parent.getParent();
  31.             if (var1 != null) {
  32.                this.nextIndex = ((DefaultMutableTreeNode)var1).getIndex(this.parent);
  33.                this.parent = var1;
  34.                this.childCount = this.parent.getChildCount();
  35.                if (this.updateNextIndex()) {
  36.                   return true;
  37.                }
  38.             } else {
  39.                this.parent = null;
  40.             }
  41.          }
  42.  
  43.          return false;
  44.       }
  45.    }
  46.  
  47.    public boolean hasMoreElements() {
  48.       return this.parent != null;
  49.    }
  50.  
  51.    public Object nextElement() {
  52.       if (!this.hasMoreElements()) {
  53.          throw new NoSuchElementException("No more visible paths");
  54.       } else {
  55.          TreePath var1;
  56.          if (this.nextIndex == -1) {
  57.             var1 = this.parent.getTreePath();
  58.          } else {
  59.             VariableHeightLayoutCache.TreeStateNode var2 = (VariableHeightLayoutCache.TreeStateNode)this.parent.getChildAt(this.nextIndex);
  60.             var1 = var2.getTreePath();
  61.          }
  62.  
  63.          this.updateNextObject();
  64.          return var1;
  65.       }
  66.    }
  67.  
  68.    protected boolean updateNextIndex() {
  69.       if (this.nextIndex == -1 && !this.parent.isExpanded()) {
  70.          return false;
  71.       } else if (this.childCount == 0) {
  72.          return false;
  73.       } else if (++this.nextIndex >= this.childCount) {
  74.          return false;
  75.       } else {
  76.          VariableHeightLayoutCache.TreeStateNode var1 = (VariableHeightLayoutCache.TreeStateNode)this.parent.getChildAt(this.nextIndex);
  77.          if (var1 != null && var1.isExpanded()) {
  78.             this.parent = var1;
  79.             this.nextIndex = -1;
  80.             this.childCount = ((DefaultMutableTreeNode)var1).getChildCount();
  81.          }
  82.  
  83.          return true;
  84.       }
  85.    }
  86.  
  87.    protected void updateNextObject() {
  88.       if (!this.updateNextIndex()) {
  89.          this.findNextValidParent();
  90.       }
  91.  
  92.    }
  93. }
  94.